<template>
  <div>
    <div class="login-head">
      <span style="color: #fff" @click="jumpFn()">
        <van-icon name="arrow-left"
      /></span>
      <span class="login-title">新增地址</span>
      <span></span>
    </div>
    <div class="add_content">
      <el-input
        v-model="inputName"
        placeholder="请填写你的姓名"
        class="add-name"
      ></el-input>
      <div @click="jumpSearchAdress()">
        <el-input
          v-model="inputChoose"
          placeholder="请选择送餐地址"
          class="add-add-address"
        ></el-input>
      </div>
      <el-input
        v-model="input"
        placeholder="请填写详情送单地址"
        class="add-add-detail-address"
      ></el-input>
      <p id="short1"></p>
      <el-input
        v-model="inputPhone"
        placeholder="请填写能联系到您的手机号"
        class="add-phone"
      ></el-input>
      <p id="short2"></p>
      <el-input
        v-model="inputSpare"
        placeholder="备用联系人电话(必填)"
        class="add-spare-phone"
      ></el-input>
      <p id="short3"></p>
    </div>
    <div class="add_bottom" style="text-align: center">
      <el-button type="success" class="add-button" @click="chargeid(), addV()"
        >新增地址</el-button
      >
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
var link = []
var x, z1, j1, text, y, j, text, z;
export default {
  name: "add_Adress",

  data() {
    return {
    
      inputName: "",
      inputChoose: "",
      input: "",
      inputPhone: "",
      inputSpare: "",
    };
  },
  mounted() {},
  methods: {
    jumpFn() {
      this.$router.back();
    },
    addV() {
      let adress = document.querySelector(".add-add-detail-address>input");
      let adressV = adress.value;
      link.push({inputPhone:this.inputPhone,input:this.input})
      window.localStorage.setItem("adressVAK", JSON.stringify(link));
    },
    chargeid() {  
      y = document.querySelector(".add-add-detail-address>input");
      x = y.value;
      if (x.length < 4) {
        text = "送餐地址太短了不能识别";
        document.getElementById("short1").innerHTML = text;
        return false;
      } else {
        text = " ";
        document.getElementById("short1").innerHTML = text;
        return true;
      }
    },

    // jumpPeopleCenter() {
    //   // this.$store.commit("Add_Adress",this.input);
    // },
    jumpSearchAdress() {
      this.$router.push({
        name: "searchAdress",
      });
    },
  },
  computed: {
    ...mapState(["adress"]),
  },
};
</script>

<style scoped>
.login-head {
  width: 100%;
  height: 1.2576rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #0092e8;
}
.login-title {
  color: white;
  position: relative;
  left: -19.9985px;
  font-size: 19.9985px;
}
.add_content {
  background-color: #fff;
}
.add_content,
.add_bottom {
  text-align: center;
}
.add-name,
.add-phone,
.add-spare-phone,
.add-add-address,
.add-add-detail-address {
  width: 95%;
  margin: 5px 0;
  background-color: #292424 !important;
}
.add-name {
  margin-top: 10px;
}
.add-button {
  width: 95%;
}
#short1,
#short2,
#short3 {
  font-size: 12px;
  color: #ea3106;
  text-align: left;
  text-indent: 1em;
}
</style>